package de.tabuma.sso.privileg;

import de.tabuma.sso.project.*;
import de.tabuma.sso.sso.*;
import de.tabuma.sso.user.*;
import de.tabuma.sso.useruserrelation.*;
import de.tabuma.customer.logik.*;
import de.tabuma.customer.entity.*;
import java.util.*;

/**
 * @author $Author: alefen $
 * @version $Revision: 1.1.1.1.2.1.2.1 $
 * @since $Date: 2010/01/13 10:23:10 $
 */
public class PrivilegWebserviceLib {
    public static void userHasPrivilegForPrivileg(Privileg privileg, String ssoId) throws Exception {

        SSO sso = SSOFacade.get(ssoId);
        Project project = ProjectFacade.get(privileg.getProjectId());
        ProjectWebserviceLib.userHasPrivilegForProject(project, ssoId);
    }

    public static int userHasPrivileg(String ssoId) throws Exception {
        if(!SSOFacade.sessionIsActiv(ssoId)) {
            throw new Exception("Session has expired.");
        }

        int groupId = SSOFacade.userHasAdminProjectPrivileg(ssoId);
        if(groupId==-1) {
            throw new Exception("User has no privileg for this action.");
        }
        return groupId;

    }
}
